package cn.t.web.ent;

import cn.t.core.enums.EnumData;
import cn.t.core.mode.PageInfoDTO;
import cn.t.core.mode.PageQueryDTO;
import cn.t.facade.CommonFacade;
import cn.t.facade.device.DeviceFacade;
import cn.t.request.QueryDeviceReq;
import cn.t.vo.device.DeviceVO;
import cn.t.vo.ent.EntDeviceDetailVO;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 企业站-智能设备管理
 */
@Slf4j
@RestController
@RequestMapping("/ent/device")

@AllArgsConstructor
public class EntDeviceController {

    private final DeviceFacade deviceFacade;
    private final CommonFacade commonFacade;

    /**
     * 智能设备列表页
     */
    @PostMapping("/page")
    public PageInfoDTO<DeviceVO> page(@RequestBody PageQueryDTO<QueryDeviceReq> request) {
        return deviceFacade.page(request);
    }

    /**
     * 货道详情
     */
    @GetMapping("/detail/{deviceId}")
    public EntDeviceDetailVO detail(@PathVariable Long deviceId) {
        return this.deviceFacade.entDetail(deviceId);
    }

    /**
     * 查询设备类型
     */
    @PostMapping("/type")
    public Map<String, List<EnumData>> getDicMap() {
        return commonFacade.getDicMap(Lists.newArrayList("deviceTypeEnum"));
    }

}

